package com.zut.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zut.dao.ExamResultDao;
import com.zut.domain.ExamResult;
import com.zut.service.ExamResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ExamResultServiceImpl implements ExamResultService {
    @Autowired
    private ExamResultDao examResultDao;


    public PageInfo<ExamResult> getAll(Integer pageNum, Integer pageSize) {
        List<ExamResult> list;
        PageHelper.startPage(pageNum, pageSize);
        list = examResultDao.getAll();
        return new PageInfo<>(list);
    }

    public boolean insert(ExamResult examResult) {
        return examResultDao.insert(examResult) > 0;
    }

    public boolean deleteById(String userId, String examId) {
        return examResultDao.deleteById(userId, examId) > 0;
    }

    public boolean update(ExamResult examResult) {
        return examResultDao.update(examResult) > 0;
    }

    public PageInfo<ExamResult> getById(Integer pageNum, Integer pageSize, String id) {
        List<ExamResult> list;
        PageHelper.startPage(pageNum, pageSize);
        list = examResultDao.getById(id);
        return new PageInfo<>(list);
    }

    public PageInfo<Map<String, String>> getExamStatus(Integer pageNum, Integer pageSize) {
        List<Map<String, String>> list;
        PageHelper.startPage(pageNum, pageSize);
        list = examResultDao.getExamStatus();
        return new PageInfo<>(list);
    }

    public PageInfo<ExamResult> getExamStatusIs(Integer pageNum, Integer pageSize) {
        List<ExamResult> list;
        PageHelper.startPage(pageNum, pageSize);
        list = examResultDao.getExamStatusIs();
        return new PageInfo<>(list);
    }

    public String getSubjectById(String id) {
        return examResultDao.getSubjectById(id);
    }

    public String getExamId(String id) {
        String examId = examResultDao.getExamId(id);
        return examId;
    }


}
